<?php

include dirname(dirname(dirname(__FILE__))) . '/include/common.php';

class webServiceGetToDo extends core {

    public function process() {
        $todo_id = $this->db->escape(trim($_POST['todo_id']));
        $user_id = intval($_POST['user_id']);
        $data = $this->db->get_row("SELECT * FROM todo_lists WHERE todo_id=$todo_id AND `user_id`='$user_id'");
        if ($data) {
            if ($data->end_time == $data->start_date) {
                $end_time = "";
            } else {
                $end_time = date('H:i:s', strtotime($data->end_time));
            }
            $this->_JSONResponse(array('error' => 0, 'title' => $data->todo_item,
            'start_date' => date('Y-m-d', strtotime($data->start_date)),
            'start_time' => date('H:i:s', strtotime($data->start_time)),
            'end_time' => $end_time
            ));
        } else {
            $this->_JSONResponse(array('error' => 1, 'msg' => 'Task does not exist'));
        }
    }

}

$processor = new webServiceGetToDo();
$processor->process();
?>